package com.qgzj.config;

import lombok.Getter;

/**
 * @Description: 系统编码枚举类
 */
public enum SystemCodeEnum {

    MANAGE_ADMIN(1, "管理后台", "admin/login_normal", "", "admin/findPassword", "", 1);



    @Getter
    private Integer code;

    @Getter
    private String desc;

    @Getter
    private String loginUrl;

    @Getter
    private String registerUrl;

    @Getter
    private String findPasswordUrl;

    @Getter
    private String passwordUrl;

    /**
     * 用户类型 1-后台用户 2-pc h5用户
     */
    @Getter
    private Integer userType;

    SystemCodeEnum(Integer code, String desc, String loginUrl, String registerUrl, String findPasswordUrl,
                   String passwordUrl, Integer type) {
        this.code = code;
        this.desc = desc;
        this.loginUrl = loginUrl;
        this.registerUrl = registerUrl;
        this.findPasswordUrl = findPasswordUrl;
        this.passwordUrl = passwordUrl;
        this.userType = type;
    }

    /**
     * @Description: 根据系统编码获取登录页面地址
     * @param code
     * @return
     */
    public static String getLoginUrlByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SystemCodeEnum systemCodeEnum : SystemCodeEnum.values()) {
            if (code.intValue() == systemCodeEnum.getCode()) {
                return systemCodeEnum.getLoginUrl();
            }
        }
        return null;
    }

    /**
     * @Description: 根据系统编码获取注册页面地址
     * @param code
     * @return
     */
    public static String getRegisterUrlByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SystemCodeEnum systemCodeEnum : SystemCodeEnum.values()) {
            if (code.intValue() == systemCodeEnum.getCode()) {
                return systemCodeEnum.getRegisterUrl();
            }
        }
        return null;
    }

    /**
     * @Description: 根据系统编码获取找回密码页面地址
     * @param code
     * @return
     */
    public static String getFindPasswordUrlByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SystemCodeEnum systemCodeEnum : SystemCodeEnum.values()) {
            if (code.intValue() == systemCodeEnum.getCode()) {
                return systemCodeEnum.getFindPasswordUrl();
            }
        }
        return null;
    }

    /**
     * @Description: 根据系统编码获取设置密码页面地址
     * @param code
     * @return
     */
    public static String getPasswordUrlByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SystemCodeEnum systemCodeEnum : SystemCodeEnum.values()) {
            if (code.intValue() == systemCodeEnum.getCode()) {
                return systemCodeEnum.getPasswordUrl();
            }
        }
        return null;
    }
    /**
     * @Description: 根据系统编码获取用户类型
     * @param code
     * @return
     */
    public static Integer getUserTypeByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SystemCodeEnum systemCodeEnum : SystemCodeEnum.values()) {
            if (code.intValue() == systemCodeEnum.getCode()) {
                return systemCodeEnum.getUserType();
            }
        }
        return null;
    }

    /**
     * 根据系统编码获取系统描述
     *
     * @param code
     * @return
     */
    public static String getDescByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SystemCodeEnum systemCodeEnum : SystemCodeEnum.values()) {
            if (code.intValue() == systemCodeEnum.getCode()) {
                return systemCodeEnum.getDesc();
            }
        }
        return null;
    }
}
